import 'package:flutter/material.dart';
import 'package:sleep/help_style.dart';

const kMaxHeigth = 150.0;

class DetailAppbar extends SliverPersistentHeaderDelegate {
  final double minHeight;
  final String title;
  final String bpm;

  DetailAppbar(this.minHeight, this.title, this.bpm);

  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return CustomPaint(
      child: Stack(
        children: [
          AppBar(
            title: Text(title),
            centerTitle: true,
            backgroundColor: HelpStyle.backgroundColor,
            elevation: 0,
          ),
        ],
      ),
    );
  }

  @override
  double get maxExtent => minHeight;

  @override
  double get minExtent => minHeight;

  @override
  bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
    return false;
  }
}

class MultipleWavesPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final paintbac = Paint()..color = Colors.blue; // 设置背景颜色
    canvas.drawRect(Rect.fromLTRB(0, 0, size.width, size.height), paintbac);

    final paint = Paint()
      ..color = Colors.black
      ..style = PaintingStyle.fill;
    final path = Path();

    path.moveTo(0, size.height * 0.7);
    path.quadraticBezierTo(size.width * 0.25, size.height * 0.65,
        size.width * 0.5, size.height * 0.7);
    path.quadraticBezierTo(size.width * 0.75, size.height * 0.75,
        size.width * 1.0, size.height * 0.7);
    path.lineTo(size.width, size.height);
    path.lineTo(0, size.height);
    path.close();
    // canvas.
    canvas.drawPath(path, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return false;
  }
}

class WaveProperties {
  final double amplitude;
  final double frequency;

  WaveProperties(this.amplitude, this.frequency);
}
